package com.po;


import java.util.HashMap;
import java.util.Map;

/**
 * 通用的返回的类
 * 
 * @author lfy
 * 
 */
public class Msg {
	private int code;
	//提示信息
	private String msg;
	
	//用户要返回给浏览器的数据
	private Map<String, Object> extend = new HashMap<String, Object>();

	public static Msg success(){
		Msg result = new Msg();
		result.setCode(200);
		result.setMsg("处理成功！");
		return result;
	}
	
	public static Msg fail(){
		Msg result = new Msg();
		result.setCode(100);
		result.setMsg("处理失败！");
		return result;
	}

	public static Msg none(){
		Msg result = new Msg();
		result.setCode(404);
		result.setMsg("用户不存在");
		return result;
	}

	public static Msg exist(){
		Msg result = new Msg();
		result.setCode(201);
		result.setMsg("号码已注册");
		return result;
	}

	public static Msg pass(){
		Msg result = new Msg();
		result.setCode(444);
		result.setMsg("验证码已过期");
		return result;
	}

	public static Msg error(){
		Msg result = new Msg();
		result.setCode(500);
		result.setMsg("验证码错误");
		return result;
	}

	public static Msg passing(){
		Msg result = new Msg();
		result.setCode(501);
		result.setMsg("正在审核。。。");
		return result;
	}

	public static Msg isv_over(){
		Msg result = new Msg();
		result.setCode(300);
		result.setMsg("短信发送频率繁忙");
		return result;
	}

	public static Msg isv_money(){
		Msg result = new Msg();
		result.setCode(301);
		result.setMsg("余额不足，请联系管理员");
		return result;
	}

	public Msg add(String key,Object value){
		this.getExtend().put(key, value);
		return this;
	}


	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Map<String, Object> getExtend() {
		return extend;
	}

	public void setExtend(Map<String, Object> extend) {
		this.extend = extend;
	}
	
	
}
